#include<bits/stdc++.h>

using namespace std;
using ll = long long;
#define endl '\n'

string words = "i*(i+i)#";
int pos = 0;
char ch = words[pos];
int no = 1;
bool flag = false;

bool exp();// E->TE'
bool expA();// E'->+TE'|;
bool term();// T->FT'
bool termA();// T'->*FT'| ;
bool factor();// F->(E)|id


void advance();

int main() {
    while (cin >> words) {
        pos = 0;
        ch = words[pos];
        no = 1;
        if (exp()) {
            cout << "syntax correct" << endl;
        } else {
            cout << "syntax error" << endl;
        }
    }
}

void error() {
    flag = true;
    cout << ("syntax error");
    return;
}

void advance() {
    if (words[pos] != '#') {
        pos++;
        ch = words[pos];
    } else {
        cout << ("syntax correct");
    }
}


// E->TE'
bool exp() {
    if (ch == '(' || ch == 'i')// ch in first E
    {
        return term() && expA();
    }
    return false;
}

// E'->+TE'|;
bool expA() {
    if (ch == '+') {
        advance();
        return term() && expA();
    } else if (ch == ')' || ch == '#')// ch in Follow expA;
    {
        return true;

    }
    return false;
}

// T->FT'
bool term() {

    if (ch == '(' || ch == 'i')// ch in first E
    {
        return factor() && termA();
    } else
        return false;
}


bool termA() {

    if (ch == '*') {

        advance();
        return factor() && termA();
    } else if (ch == ')' || ch == '#' || ch == '+')// ch in Follow termA;
    {
        return true;
    } else
        return false;
}

bool factor() {

    if (ch == '(') {

        advance();
        if (!exp())return false;
        if (ch == ')')
            advance();
        else
            return true;
    } else if (ch == 'i') {

        advance();
        return true;
    } else
        return false;
}




